import Vue from "vue";
import Router from "vue-router";
import home from "./modules/home.js";
Vue.use(Router);

export default new Router({
  mode: "hash",
  base: "/",
  routes: [
    {
      path: "/",
      redirect: "/layOut",
    },
    {
      path: "/layOut",
      name: "layOut",
      component: () => import("@/views/layOut"),
      redirect: "/home/index",
      meta: {
        keepAlive: false,
      },
      children: [
        ...home,
        {
          path: "/test",
          name: "test",
          component: () => import("@/views/test"),
          meta: {
            keepAlive: true,
          },
        },
      ],
    },
  ],

  //控制滚动条是否滚动到顶部
  scrollBehavior(to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition;
    } else {
      return {
        x: 0,
        y: 0,
      };
    }
  },
});
